package com.wotao.wotao.ai.controller;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Iterator;

@Controller
public class WebController {

    @RequestMapping("index")
    public String index() {
        //根据Tymeleaf模板，默认将返回src/main/resources/templates/index.html
        return "index";
    }

    public static void main(String[] args) {
        String s = """
                [{"generations":[{"content":"","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"第","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"第","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"一","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"一","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"天","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"天","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"：\\n","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"：\\n","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"-","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"-","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":" 上","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":" 上","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"午","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"午","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"：","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"：","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"抵","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"抵","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"达","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"达","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"黄","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"黄","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"山","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"山","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"市","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"市","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"，","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"，","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"前","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"前","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"往","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"往","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"黄","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"黄","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"山","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"山","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"市","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"市","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"区","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"区","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"的","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"的","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"酒","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"酒","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"店","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"店","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"办","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"办","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"理","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"理","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"入","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"入","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}},{"generations":[{"content":"住","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}}],"promptMetadata":[],"generation":{"content":"住","properties":{"role":"ASSISTANT"},"messageType":"ASSISTANT","choiceMetadata":{"contentFilterMetadata":null,"finishReason":null}},"generationMetadata":{"usage":{"promptTokens":0,"generationTokens":0,"totalTokens":0},"rateLimit":{"requestsLimit":0,"tokensLimit":0,"tokensReset":"PT0S","requestsReset":"PT0S","tokensRemaining":0,"requestsRemaining":0}}}]
                """;
        JSONArray jsonArray = JSONUtil.parseArray(s);
        Iterator v = jsonArray.stream().iterator();
        StringBuilder sb=new StringBuilder();
        while (v.hasNext()) {
            JSONObject jsonObject = JSONUtil.parseObj(v.next());
            String rs1 = jsonObject.get("generation").toString();
            JSONObject rs2 = JSONUtil.parseObj(rs1);
            sb.append(rs2.get("content"));
        }
        System.out.println(sb.toString());
    }
}